-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nav block: enable creation from existing WP Menus #18869
Conversation
Wanted to test this one, but I'm getting an error when running
Master branch is working fine for me. Env:
|
@marekhrabe and I are going to take this up full time again starting tomorrow. |
2a8c8f2
to
2af97da
Compare
@youknowriad I think this feature is important for continuity with WP Core. However, we cannot land it until the REST API supports Menus. However, the REST API team already have a feature Plugin for Menu endpoints that needs testing. We can develop against this Plugin. However, in order to merge the feature we'll need to wait on WP Core to release the Menu endpoints. That could take some time. I felt it was worth asking - is there any way we would consider adding an "experimental" endpoint to Gutenberg to allow READ access to Menus as a stop-gap until the WP Core REST API is updated with an official endpoint? cc @apeatling |
@getdave this seems like a good use case to bring the required endpoints from that plugin to Gutenberg and test it properly. |
@youknowriad The menus endpoint is being activily developed in the plugin still. We still have one PR that is outstand. We then need to have unit tests and tidy up the code. So to me, this still makes sense for this to live in it's own plugin for now. If you want to use it in your code base, you could bring it in using composer? |
I don't mind using composer here personally, The concern is the extra tooling but we can probably try it. |
I have created a PR for menu endpoints - #20292 |
b1ff735
to
451d9f6
Compare
Size Change: +2.07 kB (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
451d9f6
to
7c5d23c
Compare
Co-authored-by: Daniel Richards <[email protected]>
Co-authored-by: Daniel Richards <[email protected]>
Due to loading spinner we now have to wait on the dropdown before interacting.
This fix will work once a complementary update has been applied to CustomSelectControl to enable the options to have a custom classname applied.
Co-authored-by: Daniel Richards <[email protected]>
4a766b2
to
792937d
Compare
You are very welcome. Thanks for all the reviews and help. Also @draganescu (and others).
Agreed. For clarity for others coming here in the future, the feature has now been:
This makes me confident it will serve the need although there are certainly some UX and a11y improvements that could be looked at. As a result I've raised a number of followup issues that have been added to the Navigation project board. I'll look to merge this asap. |
Great work Dave!! |
This feature seems merged, but in the latest Wordpress version I can't find any Nav block... Why? How is it called? |
Hey @collimarco Marco The Nav block is for the moment only present in the Gutenberg plugin. It is missing when the Gutenberg plugin is not activated. The Nav block was not included into WordPress 5.8 because it is still in a kind of experimental phase. Which means it is for now only included in the Gutenberg plugin. It should likely be included into WordPress 5.9 when it is released in December. |
This PR allow the creation of Nav Block (items) from existing WP Menus.
Requires the experimental Menu REST API Plugin. The intent is that this endpoint gets merged into WordPress Core thereby enabling this functionality on the Block to become a reality.(update: the endpoints are now merged into Gutenberg Core).This is visually based on this mockup from @shaunandrews.
Note: the creation of the Nav Block from the Menu is a one time action. It does not keep the Nav Block items in sync with the Menu.
Depends on #20292Closes #18575
Todo
The following items are outstanding on this PR:
React state update on an unmounted component
relating toToolbarContainer
component (again not modified in this PR so unrelated???).Testing Instructions
If you notice any "lag" on inserting/selecting the Block you are probably experiencing #22823.
Does this match the approved design?
Pre-test setup
Test Flow
Create a New Post
Add Nav Block
You should not see any Menu options in the placeholder dropdown as there are no menus.
Goto Apperance -> Menus and create a new Menu but do not add any items to it.
Create a New Post
Add Nav Block
You should see the Menu you created within the dropdown. Select the Menu from the dropdown and click the "Create" button.
You should see an empty Nav Block created with no Nav Item Blocks - this reflects the empty state of your WP Menu.
Goto Appearance -> Menus and add some items to your Menu (be sure to hit "Save" to save your Menu else it will still have 0 items!).
Create a New Post
Add Nav Block
You should still see the Menu you created within the dropdown. Select the Menu from the dropdown and click the "Create" button.
You should see the Nav Block created with all of the items that exist in your WP Menu.
Test that you can still create from Pages and create an empty Nav block.
Also try the tests above on a limited network connection (simulate using Devtools "Network" tab).
How has this been tested?
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: